<? //include/PRODUCT_DETAILS_session.php

include("PRODUCT_DETAILS.php");

require_once'../include/database.php';
$conn = new Connection();
$conn->NewConnection('localhost','ecommerce','root','batavia');
class SessionPRODUCT_DETAILS { 


 
 function find($id){
    
   global $conn;
   
   $query = "select ProductDetailID,ProductID,Color,Size from PRODUCT_DETAILS where ProductDetailID='$id'";
   
   $run = mysql_query($query) or die(mysql_error());
   
   $row = mysql_fetch_array($run, MYSQL_ASSOC);
   
   $numRow = mysql_numrows($run);
   
   if($numRow)
   
   {
   
   $this->PRODUCT_DETAILS= new PRODUCT_DETAILS();


   
	$this->PRODUCT_DETAILS->setProductDetailID($row['ProductDetailID']);

 
	$this->PRODUCT_DETAILS->setProductID($row['ProductID']);

 
	$this->PRODUCT_DETAILS->setColor($row['Color']);

 
	$this->PRODUCT_DETAILS->setSize($row['Size']);

 
}
return $this->PRODUCT_DETAILS;
}

function insert($PRODUCT_DETAILS){
	global $conn;
	$query = "insert into PRODUCT_DETAILS(ProductDetailID,ProductID,Color,Size) values('".$PRODUCT_DETAILS->getProductDetailID()."','".$PRODUCT_DETAILS->getProductID()."','".$PRODUCT_DETAILS->getColor()."','".$PRODUCT_DETAILS->getSize()."')";
 
 $parse=mysql_query($query);

 }
 
 function findall(){
	$query = "select ProductDetailID,ProductID,Color,Size from PRODUCT_DETAILS";
	$parse=mysql_query($query);
	$datas = array();
	while($row=mysql_fetch_assoc($parse))
	{
		$data = array();$data['ProductDetailID'] = $row['ProductDetailID'];
		$data['ProductID'] = $row['ProductID'];
		$data['Color'] = $row['Color'];
		$data['Size'] = $row['Size'];
		$datas[] = $data;
	 }
	return $datas;
	}
	function delete($PRODUCT_DETAILS){
	$query = "delete from PRODUCT_DETAILS where ProductDetailID= '".$PRODUCT_DETAILS->getProductDetailID()."'";
	$parse=mysql_query($query);
	return $parse;

	}
	
	function update($PRODUCT_DETAILS){
	$query = "update PRODUCT_DETAILS set ProductID= '".$PRODUCT_DETAILS->getProductID()."',Color= '".$PRODUCT_DETAILS->getColor()."',Size= '".$PRODUCT_DETAILS->getSize()."' where ProductDetailID= '".$PRODUCT_DETAILS->getProductDetailID()."'";
$parse=mysql_query($query);

}


}
 //include/PRODUCT_DETAILS_session.php
